package pers.baiban.sqltoword.convert;

import cn.hutool.core.util.StrUtil;
import pers.baiban.sqltoword.enums.AllowEmpty;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author 强子初
 * @since 2023/11/28
 */
@Component
public class StringToAllowEmptyConverter implements Converter<String, AllowEmpty> {

    @Override
    public AllowEmpty convert(String source) {
        for (AllowEmpty index : AllowEmpty.values()) {
            if (StrUtil.equals(index.getVal(), source))
                return index;
        }
        return AllowEmpty.YES;
    }
}